Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@8base/web-auth0-auth-client

Package Overview
Dependencies
Maintainers
6
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@8base/web-auth0-auth-client

The 8base auth0 auth client for the `AuthProvider`.

  • 2.6.6
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

8base web auth0 auth client

The 8base auth0 auth client for the AuthProvider.

WebAuth0AuthClient

Table of Contents
  • WebAuth0AuthClient

WebAuth0AuthClient

Create an instance of the web auth0 auth client.

Parameters
  • workspaceId string Identifier of the 8base app workspace.
  • domain string Domain. See auth0 documentation.
  • clientId string Client id. See auth0 documentation.
  • redirectUri string Redurect uri. See auth0 documentation.

Usage

Without authentication profile

import { AuthContext, AuthProvider, type AuthContextProps } from '@8base/react-auth';
import { WebAuth0AuthClient } from '@8base/web-auth0-auth-client';

  const authClient = new WebAuth0AuthClient({
    domain: 'domain',
    clientId: 'client-id',
    redirectUri: `${window.location.origin}/auth/callback`,
    logoutRedirectUri: `${window.location.origin}/auth`,
  });

  const renderAuth = (auth) => {
    const authorize = async () => {
      const authData = await auth.authorize();

      await auth.setAuthState({
        token: authData.idToken,
        email: authData.email,
      });
    };

    const logout = async () => {
      await auth.purgeState();
      await auth.logout();
    };

    if (auth.isAuthorized) {
      return (
        <div>
          <p>Hi ${auth.authState.email} !</p>
          <button type='button' onClick={ logout }>Logout</button>
        </div>
      );
    }

    return (
      <div>
        <button type='button' onClick={ authorize }>Authorize with auth0<button/>
      </div>
    );
  };

  ...

  <AuthProvider authClient={ authClient }>
    ...
      <AuthContext.Consumer>
        { renderAuth }
      </AuthContext.Consumer>
    ...  
  </AuthProvider>

With custom authentication profile


...

import { WebAuth0AuthClient } from '@8base/web-auth0-auth-client';

  const authClient = new WebAuth0AuthClient({
    domain: 'domain',
    clientId: 'client-id',
    redirectUri: `${window.location.origin}/auth/callback`,
    logoutRedirectUri: `${window.location.origin}/auth`,
    workspaceId: 'workspace-id',
    profile: {
      id: 'profile-id',
    },
  });

...

With default authentication profile


...

import { WebAuth0AuthClient } from '@8base/web-auth0-auth-client';

  const authClient = new WebAuth0AuthClient({
    domain: 'domain',
    clientId: 'client-id',
    redirectUri: `${window.location.origin}/auth/callback`,
    logoutRedirectUri: `${window.location.origin}/auth`,
    workspaceId: 'workspace-id',
    profile: {
      id: 'profile-id',
      isDefault: true,
    },
  });

...

FAQs

Package last updated on 18 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc